import 'package:ball_lion/entity/match/zq_list_entity.dart';
import 'package:ball_lion/utils/utils.dart';

///imgStyle 1无图 2右图 3大图 4视频 5多图
///type 1文章 2帖子 3视频
class NewsItemEntity {
  String? content;
  int? hot;
  int? id;
  int? imgStyle;
  String? imgRatio;
  String? imgs;
  String? publishTime;
  String? publisherName;
  String? publisherId;
  String? disclaimer;
  String? media;
  String? summary;
  String? title;
  String? pv;
  String? logo;
  List<HrefItem>? hrefList;
  List<NewsItemEntity>? list;
  List<ZqListEntity>? matchList;
  int? topMatchId;
  int? top;
  String? info;
  String? video;
  int? commentNum;
  int? likeNum;
  int? isLike;
  int? isRead;
  int? collectId;
  String? h5url;
  int? classId;
  int? type;
  int? focus;
  CommentRecord? commentRecord;

  NewsItemEntity(
      {this.content,
      this.hot,
      this.id,
      this.imgStyle,
      this.imgs,
      this.disclaimer,
      this.media,
      this.publishTime,
      this.publisherName,
      this.summary,
      this.title,
      this.pv,
      this.logo,
      this.hrefList,
      this.list,
      this.matchList,
      this.topMatchId,
      this.info,
      this.top,
      this.video,
      this.commentNum,
      this.likeNum,
      this.isLike,
      this.isRead,
      this.h5url,
      this.type,
      this.imgRatio,
      this.commentRecord,
      this.publisherId,
      this.focus,
      this.collectId});

  NewsItemEntity.fromJson(Map<String, dynamic> json) {
    content = json['content'];
    hot = json['hot'];
    disclaimer = json['disclaimer'];
    media = json['media'];
    id = json['id'];
    imgStyle = json['imgStyle'];
    imgs = json['imgs'];
    publishTime = json['publicTime'];
    publisherName = json['publicerName'];
    publisherId = json['publisherId'];
    summary = json['summary'];
    title = json['title'];
    pv = json["pv"];
    logo = json["logo"];
    top = json['top'];
    info = json['info'];
    video = json['video'];
    commentNum = json['commentNum'];
    likeNum = json['likeNum'];
    isLike = json['isLike'];
    isRead = json['isRead'];
    h5url = json['h5url'];
    type = json['type'];
    imgRatio = json['imgRatio'];
    focus = json['focus'];
    collectId = json['collectId'];
    if (json['hrefList'] != null) {
      hrefList = <HrefItem>[];
      json['hrefList'].forEach((v) {
        hrefList!.add(new HrefItem.fromJson(v));
      });
    }
    if (json['list'] != null) {
      list = <NewsItemEntity>[];
      json['list'].forEach((v) {
        list!.add(NewsItemEntity.fromJson(v));
      });
    }
    if (json['matchList'] != null) {
      matchList = <ZqListEntity>[];
      json['matchList'].forEach((v) {
        matchList!.add(ZqListEntity.fromJson(v));
      });
    }
    topMatchId = json['topMatchId'];
    if (json['commentRecord'] != null) {
      commentRecord = CommentRecord.fromJson(json['commentRecord']);
    }
  }

  NewsItemEntity.fromJsonSearch(Map<String, dynamic> json) {
    id = json['id'];
    title = json['title'];
    imgs = json['img'];
    pv = json['pv'];
    publisherName = json['publisherName'];
    if (json['publishTime'] != null) {
      publishTime = Utils.formatTime(
          DateTime.parse(json['publishTime']!).millisecondsSinceEpoch);
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['content'] = this.content;
    data['hot'] = this.hot;
    data['id'] = this.id;
    data['disclaimer'] = this.disclaimer;
    data['media'] = this.media;
    data['imgStyle'] = this.imgStyle;
    data['imgs'] = this.imgs;
    data['publicTime'] = this.publishTime;
    data['publicerName'] = this.publisherName;
    data['publisherId'] = this.publisherId;
    data['summary'] = this.summary;
    data['title'] = this.title;
    data['pv'] = this.pv;
    data['logo'] = this.logo;
    data['top'] = top;
    data['info'] = info;
    data['commentNum'] = commentNum;
    data['likeNum'] = likeNum;
    data['isLike'] = isLike;
    data['isRead'] = isRead;
    data['h5url'] = h5url;
    data['type'] = type;
    data['imgRatio'] = imgRatio;
    data['focus'] = focus;
    data['collectId'] = collectId;
    if (this.hrefList != null) {
      data['hrefList'] = this.hrefList!.map((v) => v.toJson()).toList();
    }
    if (list != null) {
      data['list'] = list!.map((v) => v.toJson()).toList();
    }
    if (matchList != null) {
      data['matchList'] = matchList!.map((v) => v.toJson()).toList();
    }
    data['topMatchId'] = topMatchId;
    if (this.commentRecord != null) {
      data['commentRecord'] = this.commentRecord!.toJson();
    }
    return data;
  }
}

class CommentRecord {
  String? comment;
  int? commentNum;
  int? id;
  String? lastReplyTime;
  String? userId;
  String? userLogo;
  String? userName;

  CommentRecord(
      {this.comment,
      this.commentNum,
      this.id,
      this.lastReplyTime,
      this.userId,
      this.userLogo,
      this.userName});

  CommentRecord.fromJson(Map<String, dynamic> json) {
    comment = json['comment'];
    commentNum = json['commentNum'];
    id = json['id'];
    lastReplyTime = json['lastReplyTime'];
    userId = json['userId'];
    userLogo = json['userLogo'];
    userName = json['userName'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['comment'] = this.comment;
    data['commentNum'] = this.commentNum;
    data['id'] = this.id;
    data['lastReplyTime'] = this.lastReplyTime;
    data['userId'] = this.userId;
    data['userLogo'] = this.userLogo;
    data['userName'] = this.userName;
    return data;
  }
}

class HrefItem {
  int? extId;
  String? logo;
  String? name;
  int? type;

  HrefItem({this.extId, this.logo, this.name, this.type});

  HrefItem.fromJson(Map<String, dynamic> json) {
    extId = json['extId'];
    logo = json['logo'];
    name = json['name'];
    type = json['type'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['extId'] = this.extId;
    data['logo'] = this.logo;
    data['name'] = this.name;
    data['type'] = this.type;
    return data;
  }
}
